package com.formssi.sample.datesource;

import com.bstek.ureport.definition.datasource.BuildinDatasource;
import java.sql.Connection;
import java.sql.SQLException;
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.springframework.stereotype.Component;

/**
 * 默认数据源
 *
 * @author zhangmiao
 */
@Component()
public class MyDatasource implements BuildinDatasource {

  @Resource
  private DataSource dataSource;

  @Override
  public String name() {
    return "MyDatasource";
  }

  @Override
  public Connection getConnection() {
    try {
      return dataSource.getConnection();
    } catch (SQLException e) {
      return null;
    }
  }
}

